Computer-implemented method and system for writing and performing a data query

ABSTRACT

A computer-implemented method and system for searching over queries, writing and performing a data query. The computer-implemented method includes analyzing the query to understand elements described in the query. Further, the computer-implemented method includes extracting aliases for expressions to identify alternate names. Furthermore, the computer-implemented method includes allowing a user to annotate the elements. Moreover, the computer-implemented method includes establishing whether the query contains content for defining a new query, and if so, then enables writing a query according to a shorthand system.

TECHNICAL FIELD

Embodiments of the disclosure relate generally to the field of datasearching. Embodiments relate more particularly to allow users to writeand edit queries much more easily than before, and also to allow theusers to perform keyword searches over a collection of queries.

BACKGROUND

Database systems (also known as database management systems) areprograms that enable users to store, modify and extract information froma database. A database is an organized collection of data, for exampleuniversity data, tourism data and medical data. The most common databasesystems include MySQL, Microsoft SQL Server, Oracle, Sybase and IBM DB2.Typically, the database system is a collection of schemas, tables,queries, reports, views and other objects. For instance, a database ofnames and addresses might include entries including a resident's name,the name of the street of residence, the house number, the municipality,and a postal code such as the Zip Code in the United States.

Queries are the primary mechanism for retrieving information from thedatabase, and are formulated with questions that are presented to thedatabase in a predefined format. A greater number of database managementsystems use the Structured Query Language (SQL) standard query format. Aquery is a request for specific information from a database. Forinstance, the user may request all data entries in the database whichsatisfy the request.

Typically, there are three basic methods of querying. The first methodinvolves choosing parameters from a menu. The menu guides a user tochoose the parameters (characteristics), making it easy for the user.However, this method is not flexible.

The second method involves Query by Example (QBE) where the user isallowed to specify the fields and values that define the query. Forinstance, in a database of names and addresses, a database query mightbe directed to all residents living on a given street, specified in thequery by name. If the street is long enough to run through multiplemunicipalities, the query might additionally specify residents on thatstreet within a specified one of the municipalities.

The third method is a powerful tool that deals with query languages. Amajority of database systems require the users to request in the form ofa query written in a special query language. This method is complex asit requires the user to learn the specialized query language.

Further, for the user to write a query in a structured query language,the user must be aware of which tables contain the relevant informationand the columns within those tables that contain the relevant values.This knowledge is difficult to attain in cases where the user has notdesigned the tables and neither knows a concerned person to ask.Consequently, the user needs to keep searching until the relevant tableis found. This prolonged process of guessing may be undulytime-consuming, and may make the user frustrated.

Epigrammatically, the time required to write the query grows with anumber of factors. The factors include the number of tables in thedatabase, the number of columns in the tables and the number of possiblealternatives for any given term.

In the light of the above discussion, there appears to be a need for amethod and system for an easier way of writing queries.

OBJECT OF INVENTION

The principal object of the embodiments herein is to provide a methodand system to allow users to write and edit queries much more easilythan before.

Another object of the embodiments herein is to allow users to perform akeyword search over a collection of queries. The users search over otherpeople's queries using keywords.

SUMMARY

The above-mentioned needs are met by a computer-implemented method and asystem for writing and performing a data query.

An example of a computer-implemented method for searching over queries,writing and performing a data query includes analyzing the query tounderstand elements described in the query. Further, thecomputer-implemented method includes extracting aliases for expressionsto identify alternate names. Furthermore, the computer-implementedmethod includes allowing a user to annotate the elements. Moreover, thecomputer-implemented method includes establishing whether the querycontains content for defining a new query, and if so, then enableswriting a query according to a shorthand system.

An example of a computer program product for searching over queries,writing and performing a data query includes analyzing the query tounderstand elements described in the query. Further, the computerprogram product includes extracting aliases for expressions to identifyalternate names. Furthermore, the computer program product includesallowing a user to annotate the elements. Moreover, the computer programproduct includes establishing whether the query contains content fordefining a new query, and if so, then enables writing a query accordingto a shorthand system.

An example of a system for searching over queries, writing andperforming a data query includes a computing device. Further, the systemincludes a receiving module to receive a query written by a user of thecomputing device. Furthermore, the system includes a processorconfigured within the computing device to analyzing the query tounderstand elements described in the query, extracting aliases forexpressions to identify alternate names, allowing a user to annotate theelements and establishing whether the query contains content fordefining a new query, and if so, then enables writing a query accordingto a shorthand system.

These and other aspects of the embodiments herein will be betterappreciated and understood when considered in conjunction with thefollowing description and the accompanying drawings. It should beunderstood, however, that the following descriptions, while indicatingpreferred embodiments and numerous specific details thereof, are givenby way of illustration and not of limitation. Many changes andmodifications may be made within the scope of the embodiments hereinwithout departing from the spirit thereof, and the embodiments hereininclude all such modifications.

BRIEF DESCRIPTION OF THE VIEWS OF DRAWINGS

In the accompanying figures, similar reference numerals may refer toidentical or functionally similar elements. These reference numerals areused in the detailed description to illustrate various embodiments andto explain various aspects and advantages of the present disclosure.

FIG. 1 is a block diagram of an environment, according to theembodiments as disclosed herein;

FIG. 2 is a block diagram of a computing device, according to theembodiments as disclosed herein;

FIG. 3 is a flow diagram illustrating a method for writing andperforming a data query, according to the embodiments as disclosedherein;

FIG. 4 is a flow chart illustrating a method for keyword search overqueries, according to the embodiments as disclosed herein;

FIG. 5 is a schematic representation of exemplary tables and data storedin a database, according to the embodiments as disclosed herein;

FIG. 6 is an exemplary representation of the number of key strokes towrite a query, according to the embodiments as disclosed herein;

FIG. 7 is a block diagram of the process for writing and performing adata query, according to the embodiments as disclosed herein;

FIG. 8 illustrates an exemplary query associated with each of theobjects in the query, according to the embodiments as disclosed herein;and

FIG. 9 is a block diagram of a machine in the example form of a computersystem within which instructions for causing the machine to perform anyone or more of the methodologies discussed herein may be executed.

DETAILED DESCRIPTION OF THE EMBODIMENTS

The above-mentioned needs are met by a method and system for writing andperforming data queries. The following detailed description is intendedto provide example implementations to one of ordinary skill in the art,and is not intended to limit the invention to the explicit disclosure,as one of ordinary skill in the art will understand that variations canbe substituted that are within the scope of the invention as described.

The method described herein is applied over a data catalog (hereinreferred to as the “Alation Data Catalog”. Typically, the Alation DataCatalog is a Social Data Catalog which contains a rich source ofinformation about enterprise data and its usage by people in theenterprise.

Environment Block Diagram

FIG. 1 is a block diagram of an environment, according to theembodiments as disclosed herein. The environment 100 includes a user 102of a computing device 104, a network 106, a search engine 108 and adatabase 110.

Examples of the computing device 104 includes, but is not limited to,personal digital assistants, cellular telephones, smart phones, tabletsand other similar computing devices. The computing device 104 isoperated/owned by the user 102.

Further the computing device 104 is configured with a non-transitorycomputer-readable medium, the contents of which causes to perform themethod disclosed herein.

Network link(s) involved in the system of the present invention mayinclude any suitable number or arrangement of interconnected networksincluding both wired and wireless networks. By way of example, awireless communication network link over which mobile devicescommunicate may utilize a cellular-based communication infrastructure.The communication infrastructure includes cellular-based communicationprotocols such as AMPS, CDMA, TDMA, GSM (Global System for Mobilecommunications), iDEN, GPRS, EDGE (Enhanced Data rates for GSMEvolution), UMTS (Universal Mobile Telecommunications System), WCDMA andtheir variants, among others. In various embodiments, network link mayfurther include, or alternately include, a variety of communicationchannels and networks such as WLAN/Wi-Fi, WiMAX, Wide Area Networks(WANs), and Blue-Tooth.

The search engine 108 is a program that searches for and identifiesdocuments/websites from a Data Catalog that correspond to keywords orcharacters specified by the user. At times, the search engine 108retrieves information stored in the database 110. Examples of the searchengine 108 include, but are not limited to, Google, Bing and Yahoo!Search. Each search engine 108 has its own method of searchinginformation.

It should be appreciated by those of ordinary skill in the art that FIG.1 depicts the computing device 102 and the search engine 108 in anoversimplified manner, and a practical embodiment may include additionalcomponents and suitably configured processing logic to support known orconventional operating features that are not described in detail herein.

The user 102 requires specific information from the database 110. As aresult, the user 102 writes and edits queries much easier than beforeusing the computing device 104. The users are also allowed to searchother people's queries using specific keywords. The search is performedin real time and is advanced than traditional searches. Further, thesearch is performed across values and physical names of data objects.Additionally, the users are allowed to attach titles/labels anddescriptions to all objects and values and subsequently perform a searchover it as well.

Block Diagram of Computing Device

FIG. 2 is a block diagram of a computing device, according to theembodiments as disclosed herein. The computing device 104 includes areceiving module 202, a keyword search user interface 204, an analyzingmodule 206, a smart query editor 208 and a processor 210.

The receiving module 202 receives queries from the user. The receivingmodule 202 may, for instance, include a user input interface, and afront-end processor for interpreting the user input as an electronicquery function.

The keyword search user interface 204 to allow users to write dataqueries and interact with templates. It may include a keyboard, or adisplay with clickable icons, text menus and entries, Boolean operators,etc.

The analyzing module 206 analyzes the extracted query logs and helpsbootstrap the system even without any prior usage of our query editor. Aquery log contains a log of queries that have been made to a databasesystem. Thus, analysis of a query may begin by reading the query fromthe query log.

The smart query editor 208 allows the user to write and edit queries. Itmay include functionality similar to that of a word processor or texteditor application.

The processor 210 is configured to access a stored software code programwhich may be in system memory or on a non-transitory computer-readablemedium (content parsing algorithm), the software code program contentsof which cause to perform the method disclosed herein.

Operational Flow Chart

FIG. 3 is a flow diagram illustrating a method for writing andperforming a data query, according to the embodiments as disclosedherein. The method begins at step 302.

At step 302, the query is analyzed to understand elements described inthe query. The elements include schema, tables, attributes, attributevalues, expressions, join predicates, filters, group by columnsincluding ordering, having predicates, result columns (includingexpressions and aliases) described in the query. Each of these elementsare extracted from the query.

A schema is the structure or organization of the database. Particularly,the schema defines the tables, the fields in each table and therelationships between fields and tables. A table has a specified numberof columns and can have any number of rows. Attributes refer tocharacteristics of the table and hold values known as attribute values.Expressions in database systems enable the user to specify whichinformation the user wants to see.

For a given user-specified query attribute, attributes which arecommonly joined with the given query attribute are accessed. Referringagain to the example of a database of names and addresses, a givenmunicipality may have a given postal code associated with it.

Further, queries are collected into the Alation Catalog. The queries arecollected from the smart query editor and system query logs and aresubsequently analyzed. A search beyond logged queries is generalizedwherein literals are selectively retained within the query formodification and for creation of a new template. Subsequently, thequeries are matched to keywords that users tend to use. This includesdocument preparation by adding to the query, titles and descriptions ofdata objects, and tokens in names and titles. The queries and querytemplates are ranked by relevance. The ranking includes using tokenweights and query weights.

Basically, the query logs are analyzed to identify the following:

-   -   1. Frequencies of:        -   a. Expressions        -   b. Attribute value frequencies        -   c. Attribute mention frequencies within queries        -   d. Table mention frequencies within queries        -   e. Schema mention frequencies    -   2. Relationships between        -   a. Table sets        -   b. Attribute sets        -   c. Attribute values        -   d. Users and tables        -   e. Users and attributes        -   f. Reports and users        -   g. Expressions and aliases    -   3. Lineage        -   a. Derivation relationships between tables/data sources:            -   i. automatically derived from queries            -   ii. Extract, Transform, Load (ETL) scripts            -   iii. Ingested through API

At step 304, aliases for expressions are extracted to identify alternatenames. Aliases are extracted from queries in the log or written in theeditor. For instance, a sql query “SELECT CustomerId,SUM(RevT.Pft+RevT.Cst) as Revenue FROM RevT as CustomerRevenue GROUP BYCustomerId” has two aliases: {SUM(RevT.Pft+RevT.Cst)->Revenue,RevT->CustomerRevenue}. Such alias extraction parses the queries indetail and then resolves all objects mentions in query with objects inthe catalog. For example, FN as First name or SUM(X+Y) as Revenue. Thesealiases are used to derive synonyms. For the present purposes, an“alias” is defined as a word, expression, proper name, etc., which issynonymous with a term such as a query keyword. In an embodiment, adatabase query which specifies such a term should preferably capturedatabase entries which use the alias, as well as those which use thespecified term. “Extracting” the aliases means obtaining the aliasesused in queries.

At step 306, a user is allowed to annotate the elements. A user canannotate these elements by their initiative via a user-interface to viewand edit information about each data object. Additionally, applicationscan also annotate the elements via an API. Further, the query editor canalso prompt the user to annotate elements (which have not beentitled/described) that they are working with in the current context. Theelements include data source, schema, table, attributes, attributevalues, report, workbook/dashboard, query and expression. The user isallowed to annotate the elements with the following:

-   -   1. Title    -   2. Description    -   3. Up/Down notes    -   4. Endorsement/warning/deprecation—users can add annotations        along with comments on any of the elements.    -   5. The user is allowed to add custom fields such as        stewards/experts/owners/Data Quality Measure and populate them        either manually or using an application programming interface        (API).    -   6. Expert users    -   7. Top users    -   8. Data quality information where ever relevant.

At step 308, the query is established to check whether the querycontains content for defining a new query. If so, then the query iswritten according to a shorthand system.

A given entry at a given point is a function of the user's data entryand the syntax of the query up to the given point.

Based on the Alation Catalog, the following methods are performed forsearching specific information:

Keyword search methodology—used over the collected queries to allowusers to search and understand other user's queries using keywords.

Search-driven query formulation—wherein the smart query editor allowsusers to edit and write queries.

Keyword Search Over Queries Methodology

The Alation catalog is also considered for enabling keyword searchesover queries. Keyword search over queries methodology allows the user toperform search operation by physical names, by tokens in logical namesand by synonyms of tokens in logical names.

The search requires three components to be well-defined.

-   -   1. Repository of documents to search over    -   2. Indexing Structures    -   3. Ranking Algorithm

Generalization: An additional challenge is that of searching for querieswhich may not have been written yet. This is addressed by the generationof query templates and preparing documents to index the queries.

Generally, a large set of queries are collected from the smart queryeditor and extracted from the database system's query logs. All queriesthat are executed by the database system are periodically extracted fromthe database query log tables. A majority of the databases store theexecuted queries along with the user's names who executed the queriesand details of the query execution.

Keyword search over queries methodology combines common queries (andpredicates) into one template as query and predicate template, whichallows the user to search for “new/unseen” queries, based on past querypatterns. A query template is one which when instantiated fully resultsin an executable query. To “instantiate” a query template means toinsert keywords, values, etc., for each variable. For example, ‘selectage, gender, count (*) from customer_demographics where region=$1 groupby age, gender’. For instance, if “region=$1” is a predicate for theregion of the state of California, then instantiating this querytemplate would include replacing region=$1 with California or anappropriate alphanumeric code based on the data semantics. Similarly, apredicate template are those which when instantiated results in a partof a query. For example, a predicate “region=$1” might represent akeyword denoting a particular geographic region, such as “California”.In some embodiments, instantiated queries may not be present in thequery log or in the catalog. New queries may be made by “generatingtemplates” and then “instantiating” values for templates based on auser's search.

The creation of a template replaces all literals in a query withvariables. However, the literals that can be retained without replacingit with variables, is automatically determined. Especially, literalsthat don't vary as often may not be replaced with variables whilegenerating templates. The user can modify an existing template andcreate a new template. Further, a new template is created with literalsthat do not change over a specific time period upon execution.

Each query is associated with each of the objects in the query (tables,columns, filters, join predicates, derived columns, values, etc.). Theseassociations are used for preparing a searchable/indexable document.

Each object (tables, columns and derived columns) in the database (forinstance, schema, table, column (pre-defined or derived), value, filtersand join predicates) are described in human understandable terms. Forexample, a schema “CRV” is “Customer Revenue” database and a table“RevT” is titled as “Revenue of Customers” and so on. Similarly, aderived column such as “Rev-Cst” is titled as “Customer Profit”. Suchdata dictionaries are “ingested” and associated with each table/columnwith their logical titles and descriptions. The logical descriptions ofthe objects are also deduced from the aliases used in queries that areingested.

In keyword search over queries methodology, documents are prepared toindex queries such that they match the keywords to be used, enablingsearch over the templates. Each document is composed of query text anduser profiles. The query text includes tokens from the physical names oftables, attributes and so on. Some queries are titled and well-describedspecifically when authored in the Alation query editor. Further,profiles of user's who have been authored and interacted with the queryin other ways are included in the document. Additionally, the followingcomponents are also included in the document:

1. Titles and descriptions of data objects mentioned in the query. Thedata objects include tables, attributes, predicates and attributevalues.

2. Snippets of query.

3. Propagated aliases that were used for data objects in other queries.Consider the following queries:

Q1: ‘SELECT SUM(X+Y) as Revenue FROM CRevenue as Customer_Revenue’ and

-   -   Q2: ‘SELECT State, SUM(X+Y) FROM CRevenue, CAddress on        CRevenue.CID=CAddress. CID group by CAddress.State’    -   Here, by propagating aliases ‘Revenue’ and ‘Customer_Revenue’ to        the expression SUM (X+Y) and CRevenue, respectively from Q1 and        Q2, Q2 can now be found when a user searches for [Customer        Revenue by State].

Further, documents are enhanced for query templates with the followinginformation:

-   -   1. Attribute values that could be used to instantiate template        parameters and    -   2. Tokens in physical names or logical titles of the attribute        values that could instantiate template parameters.

The query-object association and logical title/descriptions of objectssupports keyword search over queries based on the keywords in thelogical titles/descriptions of the objects (tables, columns, filters, .. . ) involved. For instance consider, a sql query “select * fromCRV.RevT where sc_code in (1, 5, 9, 11)”

-   -   Here, CRV is “Customer Revenue”, RevT is “Revenue of customers”,        and consider that sc_code in (1, 5, 9, 11) is “northeast        states”. Now, if a user's keyword search query is [revenue        northeast], the above sql query is matched for this keyword        query.

Further, in keyword search over queries methodology inverted indexstructure is employed over the prepared documents.

Keyword search over queries methodology includes ranking, where theprepared documents (corresponding to either queries or query/predicatetemplates) are ranked based on token weights or query/template weights,returning the most relevant queries or query templates to a user'squery.

Search-Driven Query Formulation

The search-driven query formulation automatically suggests querysnippets based on current context, prefix of tokens and keyword searchfor predicates or templates. A “predicate” means, for the purposes ofthe present subject matter, an expression which is defined as having asynonymous meaning with a search keyword which a user might use in aquery, and whose syntax may be defined so as to represent a class ofkeywords in a standardized manner. For instance, keywords for colorsmight be familiar color terms such as “black,”“blue,”“red,” etc.Predicates for such keywords might have a syntax such as “clr_code=#”where clr_code is an abbreviation for “color code,” and the # representsan index number, whose various values correspond with different keywordswithin the class. For example, if the index number 3 corresponds withthe color black, then “clr_code=3” might be a predicate for the keyword“black.” On-the-fly suggestions can be further narrowed down by allowingthe user to search with prefixes or tokens in physical names and inlogical names. Further, the search-driven query formulation showspreviews, endorsements, warnings, comments, top users, expert users andother relevant information about the objects being suggested and used inthe current query.

The search-driven query formulation implements ranking of autosuggestion using:

-   -   1. Popularity/frequency of attributes, tables, attribute values,        expressions.    -   2. Co-mention frequency of table-table, table-attribute,        attribute-attribute, expression-attribute, expression-table,        expression-expression.    -   3. Frequency of mention that is specific to each user.

In the search-driven query formulation the content of the suggestionmenu is automatically filtered by context (for example, which tokensprecede and follow the cursor, which tables and attributes have beenmentioned so far and so on), sorted by anticipated relevance (based onthe usage patterns of the user and peers), and can be searchedexplicitly (over physical names as well as human-annotated labels).

The search-driven query formulation algorithms include pre-materializingthe index, per-schema materialization and personalization (by relevantschemas) per user and on-the-fly suggestions. Here, the search isleveraged over queries and snippets of queries to enable a lot of thefunctionality.

In the pre-materialization algorithm of the search-driven queryformulation, predicates are materialized along with auto-generatedtitles (as mentioned is paragraph [0046]) and are indexed. Thesepredicates are marked as auto-generated; and whenever the user edits onthe title or on the predicate text, an auto-generated flag is reset.Materializing the predicates is advantageous in several ways as listedbelow:

-   -   1. It is easier to add new sophisticated classes of predicates        as they can be materialized offline.    -   2. Titles can also be generated offline.    -   3. It is treated the same way as any other predicate.    -   4. Can also be a part of the Alation catalog.

On-the-fly suggestions algorithm of the search-driven query formulation,generates suggestions based on the context during compose time.Therefore, it is beneficial, as suggestions can be more relevant.

The challenge is which part of the index should be on the server andwhich parts should be on the client browser. The method described hereinrelies on pre-computation and partitioning the index into multiplechunks. This approach has two advantages: i) Graceful experience ii) aquick start where the user doesn't need to wait for all of the indexesto be downloaded before she gets any recommendations.

-   -   1. The method described herein splits the index into multiple        pieces:        -   a. By suggestion types (for instance, columns, tables,            filters, joins, values)        -   b. By schema    -   2. When the user starts using the query editor, tables and        columns indexes for the schemas most commonly used by the user        are displayed. In some embodiments, additional indexes are        displayed progressively based on availability of RAM.

Consider that the user has typed in a query as follows:

-   -   SELECT * FROM purchases WHERE    -   and then the user types ‘blac’ from a menu list of specified        colors.

The method described herein finds the value of ‘black’ in the table‘colors’ and traces back the foreign key relationship to purchases.Subsequently, the entire string is suggested to the user: A queryexpression, in appropriate syntax, might be as follows:clr_code=3/*black*/

In other words, as the user types keywords while writing queries,predicates are prepared and instantiated. For instance, clr_code=3 whenthe user types “black” and typ_code IN (44, 89, 102, 113) when the usertypes “footwear”.

Typically, relationships are deduced from declared foreign keys and arestored in the query log. In addition to the foreign key relationships,other relationships from a catalog (known as the ‘Alation catalog’) areused. Related attributes which are commonly joined with the currentattribute in context is also referred. The joining attributes which aretagged as “enumerated” in the Alation Catalog are also prioritized andincludes a “descriptive” attribute. For example, purchases.clr_code maycommonly be joined with the ClrDescr.Code attribute of the ClrDescrtable. The ClrDescr table holds the schema as [Code, Descr].

The method ends at step 308.

The method described in FIG. 3 is specifically beneficial for thefollowing reasons:

-   -   1. The entire process of writing queries is much faster than        traditional methods.    -   2. The method eliminates the need to have multiple tabs open.    -   3. The method eliminates the need to enquire with colleagues or        store attribute values in mind.    -   4. The method eliminates the requirement of pre-queries.    -   5. With context, sorting, searching and previewing, the user can        write a query easily in one pass.    -   6. The presence of a trie index on the client device (which is        shipped from the server) avoids network delays in suggestions in        the smart query editor.

FIG. 4 is a flow chart illustrating a method for keyword search overqueries, according to the embodiments as disclosed herein. The methodbegins at step 402.

At step 402, a keyword search is performed over the query repository.

At step 404, results are examined and one result (query) is selected tofurther understand and explore.

At step 406, the selected query is opened in smart query editor andmodify.

At step 408, the query is executed.

The method ends at step 408.

Exemplary Representation of Tables in a Database

FIG. 5 is a schematic representation of exemplary tables and data storedin a database, according to the embodiments as disclosed herein. While adatabase of names and addresses was briefly mentioned above, here adatabase of garments will be examined in more detail.

The tables are defined as Apparel_types 502, Sizes 504, Colors 506 andPurchases 508. Further, the tables Apparel_types 502, Sizes 504, Colors506 include attributes ‘code’ and ‘descr’. The attribute values for thetable Apparel_types 502 includes ‘44 shoes’, ‘45 T-shirt’ and ‘46hoodie’. Similarly, the attribute values for the table Sizes 504includes ‘6 L’, ‘7 XL’ and ‘8 XXL’. Further, the attribute values forthe table Colors include ‘2 White’, ‘3 Black’ and ‘4 Blue’.

The table Purchases 508 include attributes ‘id’, ‘date’, ‘typ_code’,‘sz_code’ and ‘clr_code’. The attribute values are listed below, forexample ‘1204’, ‘12-06-2012’, ‘100’, ‘4’, ‘15’.

Exemplary Representation of Key Strokes to Write a Query

FIG. 6 is an exemplary representation of the number of key strokes towrite a query, according to the embodiments as disclosed herein.

This functionality relies on the ability to “search” for snippets ofqueries. The search is based on (a) context of the partially typedquery, (b) user's context (team/org), (c) current cursor context(partially typed tokens).

Consider the normal method to write a query as shown below:SELECT * FROM purchases WHERE typ_code=45 AND sz_code=7 AND clr_code=3.

With the method described herein, the same query is written using twentykey strokes as shown in FIG. 6 thereby making it easier and faster forthe user to write the query. In FIG. 6, the middle column “Effect”represents the elements of the written query; that is, the query can beunderstood by reading down the Effect column: SELECT FROM purchasesWHERE t-shirts AND extra large size AND black.

The left column represents user keystrokes. The keystrokes relate topredetermined query syntax. Accordingly, the keystroke sequence followsthe query syntax from beginning to end, and a given keystroke at a givenpoint within the query is interpreted to have a meaning whichcorresponds with the parameter value, Boolean operator, etc., which iscalled for at that point in the query.

Thus, a relatively small number of distinct shorthand keystrokes maybuild an elaborate query. Note, for instance, the number of ENTERkeystrokes in the Press column, and the various meanings given in theEffect column, depending on where we are in the query syntax. Noticealso the abbreviations (such as “ts” for t-shirt), and the DOWNkeystroke for scrolling through a menu of colors. Either productabbreviations (such as “ts” for t-shirt), or DOWN and UP strokes througha menu of options for a given parameter, may be used.

Process Block Diagram

FIG. 7 is a block diagram of the process for writing and performing adata query, according to the embodiments as disclosed herein.

The block diagram illustrates the Query Repository 702 that performsquery analysis 704. Relevant phrases that can be used to describesnippets of a query are auto-generated based on the analysis performedover Query Logs 706 and Queries from editors 708.

Logical Titles/Descriptions 710 are ingested or can be user-annotatedand are used to create data graphs 712.

As described in FIG. 3, specific information can be searched using twomethods, Keyword Search over Queries 714 and Search-driven QueryFormulation 716. Both the methods support two types of search queries.The Keyword Search over Queries 714 performs over the query repository.The Search-driven Query Formulation 716 enables search queries whichtake the context of a user's query and then returns the best suggestionfor the user's context. These can return several types: tables, columns,expressions, predicates, schema and so on. They take as input a partialquery context including the characters that the user just typed tofilter suggestions appropriately.

Consequently, two types of indexes are build: a standard inverted indexfor keyword search, and a trie-based index structure to search forrelevant candidates based on prefixes. The number of times a trie-basedindex is accessed by a single user editing or authoring a single queryis very high. In order to avoid the network latency and the consequentdeterioration in experience, a trie index is created for each schema.For a given user, we understand the frequently used schema and then shipthose trie indexes first to the user so that they can start receivingrelevant suggestions almost immediately.

FIG. 8 illustrates an exemplary query associated with each of theobjects in the query, according to the embodiments as disclosed herein.The objects in the query are tables, columns, filters, join predicates,derived columns, values and so on.

System Block Diagram

FIG. 9 is a block diagram of a machine in the example form of a computersystem within which instructions for causing the machine to perform anyone or more of the methodologies discussed herein may be executed. Inalternative embodiments, the machine operates as a standalone device ormay be connected (e.g., networked) to other machines. In a networkeddeployment, the machine may operate in the capacity of a server or aclient machine in a server-client network environment, or as a peermachine in a peer-to-peer (or distributed) network environment. Themachine may be a personal computer (PC), a tablet PC, a set-top box(STB), a Personal Digital Assistant (PDA), cellular telephone, awearable computing device, a computing device connected to a displaythat can understand human gestures, a web appliance, a network router,switch or bridge, or any machine capable of executing instructions(sequential or otherwise) that specify actions to be taken by thatmachine. Further, while only a single machine is illustrated, the term“machine” shall also be taken to include any collection of machines thatindividually or jointly execute a set (or multiple sets) of instructionsto perform any one or more of the methodologies discussed herein.

The example computer system 900 includes a processor 902 (e.g., acentral processing unit (CPU), a graphics processing unit (GPU), orboth), a main memory 904, and a static memory 906, which communicatewith each other via a bus 908. The computer system 900 may furtherinclude a video display unit 910 (e.g., a liquid crystal display (LCD)or a cathode ray tube (CRT)). The computer system 900 also includes analphanumeric input device 912 (e.g., a keyboard), a user interface (UI)navigation device 914 (e.g., a mouse), a disk drive unit 916, a signalgeneration device 918 (e.g., a speaker), and a network interface device920. The computer system 900 may also include an environmental inputdevice 926 that may provide a number of inputs describing theenvironment in which the computer system 900 or another device exists,including, but not limited to, any of a Global Positioning Sensing (GPS)receiver, a temperature sensor, a light sensor, a still photo or videocamera, an audio sensor (e.g., a microphone), a velocity sensor, agyroscope, an accelerometer, and a compass.

Machine-Readable Medium

The disk drive unit 916 includes a machine-readable medium 922 on whichis stored one or more sets of data structures and instructions 924(e.g., software) embodying or utilized by any one or more of themethodologies or functions described herein. The instructions 924 mayalso reside, completely or at least partially, within the main memory904 and/or within the processor 902 during execution thereof by thecomputer system 900, the main memory 904 and the processor 902 alsoconstituting machine-readable media.

While the machine-readable medium 922 is shown in an example embodimentto be a single medium, the term “machine-readable medium” may include asingle medium or multiple media (e.g., a centralized or distributeddatabase, and/or associated caches and servers) that store the one ormore instructions 924 or data structures. The term “non-transitorymachine-readable medium” shall also be taken to include any tangiblemedium that is capable of storing, encoding, or carrying instructionsfor execution by the machine and that cause the machine to perform anyone or more of the methodologies of the present subject matter, or thatis capable of storing, encoding, or carrying data structures utilized byor associated with such instructions. The term “non-transitorymachine-readable medium” shall accordingly be taken to include, but notbe limited to, solid-state memories, and optical and magnetic media.Specific examples of non-transitory machine-readable media include, butare not limited to, non-volatile memory, including by way of example,semiconductor memory devices (e.g., Erasable Programmable Read-OnlyMemory (EPROM), Electrically Erasable Programmable Read-Only Memory(EEPROM), and flash memory devices), magnetic disks such as internalhard disks and removable disks, magneto-optical disks, and CD-ROM andDVD-ROM disks.

Transmission Medium

The instructions 924 may further be transmitted or received over acomputer network 950 using a transmission medium. The instructions 924may be transmitted using the network interface device 920 and any one ofa number of well-known transfer protocols (e.g., HTTP). Examples ofcommunication networks include a local area network (LAN), a wide areanetwork (WAN), the Internet, mobile telephone networks, Plain OldTelephone Service (POTS) networks, and wireless data networks (e.g.,WiFi and WiMAX networks). The term “transmission medium” shall be takento include any intangible medium that is capable of storing, encoding,or carrying instructions for execution by the machine, and includesdigital or analog communications signals or other intangible media tofacilitate communication of such software.

As described herein, computer software products can be written in any ofvarious suitable programming languages, such as C, Objective C, Swift,C++, C#, Pascal, Fortran, Perl, Matlab (from Math Works), SAS, SPSS,JavaScript, Python, Ruby, Ruby on Rails, AJAX, and Java. The computersoftware product can be an independent application with data input anddata display modules. Alternatively, the computer software products canbe classes that can be instantiated as distributed objects. The computersoftware products can also be component software, for example Java Beans(from Sun Microsystems) or Enterprise Java Beans (EJB from SunMicrosystems). Much functionality described herein can be implemented incomputer software, computer hardware, or a combination.

Furthermore, a computer that is running the previously mentionedcomputer software can be connected to a network and can interface toother computers using the network. The network can be an intranet,internet, or the Internet, among others. The network can be a wirednetwork (for example, using copper), telephone network, packet network,an optical network (for example, using optical fiber), or a wirelessnetwork, or a combination of such networks. For example, data and otherinformation can be passed between the computer and components (or steps)of a system using a wireless network based on a protocol, for exampleWi-Fi (IEEE standard 802.11 including its substandards a, b, e, g, h, i,n, ac, et al.). In one example, signals from the computer can betransferred, at least in part, wirelessly to components or othercomputers.

It is to be understood that although various components are illustratedherein as separate entities, each illustrated component represents acollection of functionalities which can be implemented as software,hardware, firmware or any combination of these. Where a component isimplemented as software, it can be implemented as a standalone program,but can also be implemented in other ways, for example as part of alarger program, as a plurality of separate programs, as a kernelloadable module, as one or more device drivers or as one or morestatically or dynamically linked libraries.

As will be understood by those familiar with the art, the invention maybe embodied in other specific forms without departing from the spirit oressential characteristics thereof. Likewise, the particular naming anddivision of the portions, modules, agents, managers, components,functions, procedures, actions, layers, features, attributes,methodologies and other aspects are not mandatory or significant, andthe mechanisms that implement the invention or its features may havedifferent names, divisions and/or formats.

Furthermore, as will be apparent to one of ordinary skill in therelevant art, the portions, modules, agents, managers, components,functions, procedures, actions, layers, features, attributes,methodologies and other aspects of the invention can be implemented assoftware, hardware, firmware or any combination of the three. Of course,wherever a component of the present invention is implemented assoftware, the component can be implemented as a script, as a standaloneprogram, as part of a larger program, as a plurality of separate scriptsand/or programs, as a statically or dynamically linked library, as akernel loadable module, as a device driver, and/or in every and anyother way known now or in the future to those of skill in the art ofcomputer programming. Additionally, the present invention is in no waylimited to implementation in any specific programming language, or forany specific operating system or environment.

Furthermore, it will be readily apparent to those of ordinary skill inthe relevant art that where the present invention is implemented inwhole or in part in software, the software components thereof can bestored on computer readable media as computer program products.

Any form of computer readable medium can be used in this context, suchas magnetic or optical storage media. Additionally, software portions ofthe present invention can be instantiated (for example as object code orexecutable images) within the memory of any programmable computingdevice.

As will be understood by those familiar with the art, the invention maybe embodied in other specific forms without departing from the spirit oressential characteristics thereof. Likewise, the particular naming anddivision of the portions, modules, agents, managers, components,functions, procedures, actions, layers, features, attributes,methodologies and other aspects are not mandatory or significant, andthe mechanisms that implement the invention or its features may havedifferent names, divisions and/or formats.

Accordingly, the disclosure of the present invention is intended to beillustrative, but not limiting, of the scope of the invention, which isset forth in the following claims.

The invention claimed is:
 1. A computer-implemented method for searchingover queries, writing and performing a data query, the method performedby a processor configured within a computing device comprising:analyzing, the query to understand elements described in the query,wherein the query elements include a keyword and a predicate and whereinthe query is collected from the smart query editor and system querylogs; determining, if the elements include a predicate, andinstantiating the predicate; extracting aliases for expressions toidentify alternate names for the query; allowing a user to annotate theelements, wherein the smart query editor prompts the user to annotateelements based on the current context; determining whether the querycontains content for defining query syntax, and if so, then writing thequery according to a shorthand system; performing keyword search by theuser using physical names, tokens in logical names and synonyms oftokens in logical names, wherein keyword search is executed by combiningcommon queries and predicates into one template as query and predicatetemplate, enabling the user to search for new queries based on pastquery pattern; automatically suggesting query snippets to the user basedon the current context, prefix of tokens and keyword search forpredicates or templates, wherein the predicates are materialized withauto- generated titles and are reset when the user edits on the title oron the predicate text; collecting queries into a catalog, the queriesbeinq collected from a smart query editor and system query logs;generalizing a search beyond logged queries; matching queries tokeywords that users tend to use; and ranking queries and query templatesby relevance.
 2. The computer-implemented method of claim 1 wherein thewriting the query includes using a shorthand system wherein a givenentry at a given point is a function of (i) the user's data entry and(ii) the syntax of the query up to the given point.
 3. Thecomputer-implemented method of claim 1 wherein the analyzing the queryto understand elements described therein, the elements include schema,tables, attributes, attribute values, predicates, and expressionsdescribed in the query.
 4. The computer-implemented method of claim 1wherein the analyzing includes, for a given query attribute, looking upattributes which are commonly joined with the given queryattribute. 5.The computer-implemented method of claim 1, wherein the generalizingincludes selectively retaining literals within the query formodification and for creation of a new template.
 6. Thecomputer-implemented method of claim 1, wherein the matching queries tokeywords includes document preparation by adding, to the query, titlesand descriptions of data objects, and tokens in names and titles.
 7. Thecomputer-implemented method of claim 1, wherein the ranking includesusing token weights and query weights.
 8. The computer-implementedmethod of claim 1, further comprising generating and logging a newtemplate.
 9. A computer program product stored on a non-transitorycomputer- readable medium that when executed by a processor, performs amethod for searching, writing and performing a data query, comprising:analyzing the query to understand elements described in the query,wherein the query elements include a keyword and a predicate and whereinthe query is collected from the smart query editor and system querylogs; determining if the elements include a predicate, and instantiatingthe predicate; extracting aliases for expressions to identify alternatenames for the query; allowing a user to annotate the elements, whereinthe smart query editor prompts the user to annotate elements based onthe current context; determining whether the query contains content fordefining a query syntax, and if so, then writing the query according toa shorthand system; performing keyword search by the user using physicalnames, tokens in logical names and synonyms of tokens in logical names,wherein keyword search is executed by combining common queries andpredicates into one template as query and predicate template, enablingthe user to search for new queries based on past query pattern;automatically suggesting query snippets to the user based on the currentcontext, prefix of tokens and keyword search for predicates ortemplates, wherein the predicates are materialized with auto- generatedtitles and are reset when the user edits on the title or on thepredicate text; collecting queries into a catalog, the queries beingcollected from a smart query editor and system query logs; generalizinga search beyond logged queries; matching queries to keywords that userstend to use; and ranking queries and query templates by relevance. 10.The computer program product of claim 9 wherein the writing the queryincludes using a shorthand system wherein a given entry at a given pointis a function of (i) the user'sdata entry and (ii) the syntax of thequery up to the given point.
 11. The computer program product of claim 9wherein the analyzing the query to understand elements describedtherein, the elements include schema, tables, attributes,attributevalues, predicates and expressions described in the query.
 12. Thecomputer program product of claim 9 wherein the analyzing includes, fora given query attribute, looking up attributes which are commonly joinedwith the given query attribute.
 13. The computer program product ofclaim 9 wherein the generalizing includes selectively retaining literalswithin the query for modification and for creation of a new template.14. The computer program product of claim 9 wherein matching queries tokeywords includes document preparation by adding, to the query, titlesand descriptions of data objects, and tokens in names and titles. 15.The computer program product of claim 9 wherein the ranking includesusing token weights and query weights.
 16. The computer-implementedmethod of claim 9, further comprising generating and logging a newtemplate.
 17. A system for searching, writing and performing a dataquery, the system comprising: a computing device; a receiving module toreceive a query written by a user of the computing device; a processorconfigured within the computing device to: analyzing the query tounderstand elements described in the query, and wherein the query iscollected from the smart query editor and system query log; determining,if the elements include a predicate, and instantiating the predicate;extracting aliases for expressions to identify alternate names; allowinga user to annotate the elements wherein the smart query editor promptsthe user to annotate elements based on the current context; determiningwhether the query contains content for defining a query syntax, and ifso, then writing the query according to a shorthand system; performingkeyword search by the user using physical names, tokens in logical namesand synonyms of tokens in logical names, wherein keyword search isexecuted by combining common queries and predicates into one template asquery and predicate template, enabling the user to search for newqueries based on past query pattern; automatically suggesting querysnippets to the user based on the current context, prefix of tokens andkeyword search for predicates or templates, wherein the predicates arematerialized with auto-generated titles and are reset when the useredits on the title or on the predicate text; collecting queries into acatalog, the queries being collected from a smart query editor andsystem query lops; generalizing a search beyond lowed queries; matchingqueries to keywords that users tend to use; and ranking queries andquery templates by relevance.
 18. The system of claim 17 and furthercomprising: a keyword search user interface to allow users to write dataqueries and interact with templates; a data storage device storingsocial data catalogs and corresponding usage by users, the social datacatalogs includes a source of information; and a smart query editorconfigured within the computing device to allow users to edit and writequeries. a search engine to search and identify items in the datastorage device that correspond to keywords and characters specified by auser. an analyzing module configured within the computing device toanalyze extracted query.